
package com.aiyige.model.moment.backup;

import android.os.Parcel;
import android.os.Parcelable;

public class CommodityBackup implements Parcelable{

    /**
     * 价格，单位：元
     */
    private Double price;
    /**
     * 单次价格，单位：元
     */
    private Double unitPrice;
    /**
     * 原价，单位：元
     */
    private Double originPrice;


    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Double getUnitPrice() {
        return unitPrice;
    }

    public void setUnitPrice(Double unitPrice) {
        this.unitPrice = unitPrice;
    }

    public Double getOriginPrice() {
        return originPrice;
    }

    public void setOriginPrice(Double originPrice) {
        this.originPrice = originPrice;
    }

    public CommodityBackup() {
    }

    public CommodityBackup(CommodityBackup other) {
        if (other == null) {
            this.price = 0d;
            this.unitPrice = 0d;
            this.originPrice = 0d;
        } else {
            this.price = other.price == null ? 0d : other.price;
            this.unitPrice = other.unitPrice == null ? 0d : other.unitPrice;
            this.originPrice = other.originPrice == null ? 0d : other.originPrice;
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeValue(this.price);
        dest.writeValue(this.unitPrice);
        dest.writeValue(this.originPrice);
    }

    protected CommodityBackup(Parcel in) {
        this.price = (Double) in.readValue(Double.class.getClassLoader());
        this.unitPrice = (Double) in.readValue(Double.class.getClassLoader());
        this.originPrice = (Double) in.readValue(Double.class.getClassLoader());
    }

    public static final Creator<CommodityBackup> CREATOR = new Creator<CommodityBackup>() {
        @Override
        public CommodityBackup createFromParcel(Parcel source) {
            return new CommodityBackup(source);
        }

        @Override
        public CommodityBackup[] newArray(int size) {
            return new CommodityBackup[size];
        }
    };
}